package cn.easybuy.web.pre;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.easybuy.entity.Product;
import cn.easybuy.service.ProductService;
import cn.easybuy.service.impl.ProductServiceImpl;

public class ProductServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id=request.getParameter("id");
		ProductService pService=new ProductServiceImpl();
		List<Product> listpProducts=pService.geallProducts(Integer.parseInt(id));
		
		for (Product product : listpProducts) {
			request.setAttribute("id", product.getId());
			request.setAttribute("price", product.getPrice());
			request.setAttribute("name", product.getName());
		}
		
		request.getRequestDispatcher("Product.jsp").forward(request, response);		
	}
	
}
